﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IT Helpdesk Form.aspx.cs"
    Inherits="Trig_AMJ_IT_Forms.Layouts.Trig_AMJ_IT_Forms.IT_Helpdesk_Form" DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="trig" TagName="userInfo" Src="~/_controltemplates/Trig_AMJ_IT_Forms/UserProfileInfo.ascx" %>
<%@ Register TagPrefix="trig" TagName="ITComments" Src="~/_controltemplates/Trig_AMJ_AMG_Forms/TrigAMJFormsComments/TrigAMJFormsCommentsUserControl.ascx" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link rel="Stylesheet" type="text/css" href="/_layouts/1033/STYLES/Themable/FORMS.CSS" />
    <%-- <link rel="Stylesheet" type="text/css" href="/_layouts/1033/STYLES/Almajedcustomstyles/Customformcss.css" />--%>
    <link rel="Stylesheet" type="text/css" href="/Style Library/Al Majed/CSS/Trig_IT.css" />
    <script src="/_layouts/Scripts/validations.js" type="text/javascript" language="javascript"></script>
    <style type="text/css">
        #s4-leftpanel
        {
            display: none;
        }
        .s4-ca
        {
            margin-left: 0px;
        }
        .ms-validations
        {
            color: Red;
        }
    </style>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Panel ID="pnlFullForm" runat="server" CssClass="pnlAMFform">
        <table class="tbl-main" width="800" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="4" class="formtitle">
                    IT Helpdesk
                </td>
            </tr>
            <tr>
                <td colspan="4" class="Note-td">
                    <asp:Label ID="lblnote1" runat="server" Text="Some notes will be come here!!!" CssClass="Notes-msg"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    Reference No :
                </td>
                <td colspan="2">
                    <asp:Label ID="lblTxkNo" runat="server" Text="Reference number will be generated upon save"
                        Font-Bold="True" Font-Size="XX-Small" CssClass="ms-long ms-spellcheck-true" ForeColor="Red"></asp:Label>
                </td>
                <td colspan="1" rowspan="3" align="right" class="UserInfo-Sec-td">
                    <trig:userInfo runat="server" ID="userInfo" Visible="true" />
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    Date of filling :
                </td>
                <td colspan="2">
                    <SharePoint:DateTimeControl ID="dtpDate" runat="server" DateOnly="true" IsRequiredField="true"
                        LocaleId="2057" Enabled="false" ErrorMessage="Please specify the date" />
                </td>
            </tr>
            <asp:Panel ID="pnlSec" runat="server">
                <tr>
                    <td colspan="3">
                        <asp:RadioButtonList ID="rdBtn" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"
                            AutoPostBack="true">
                            <asp:ListItem Text="Logged in User  " Value="0" Selected="True"></asp:ListItem>
                            <asp:ListItem Text="On Behalf of" Value="1"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
            </asp:Panel>
            <asp:Panel ID="pnlReqEmpInf" runat="server" Visible="false" CssClass="pnlAMFform">
                <tr>
                    <td class="tdHeadingTextLeftAlign" colspan="4">
                        Requested Employee Information
                    </td>
                </tr>
                <tr>
                    <td height="23">
                        Employee Name <span title="This is a required field." class="ms-validations"><strong>
                            *</strong></span>
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtReqUser" Text="" Visible="false"></asp:TextBox>
                        <SharePoint:PeopleEditor ID="pplReqUser" runat="server" MultiSelect="false" AutoPostBack="true"
                            Width="250px" />
                    </td>
                    <td>
                        Employee ID
                    </td>
                    <td>
                        <asp:TextBox ID="txtReqUserID" runat="server" ReadOnly="true" CssClass="txt-readonly"
                            Width="250px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Division
                    </td>
                    <td>
                        <asp:TextBox ID="txtReqUserDivision" runat="server" ReadOnly="true" CssClass="txt-readonly"
                            Width="250px"></asp:TextBox>
                    </td>
                    <td>
                        Department
                    </td>
                    <td>
                        <asp:TextBox ID="txtReqUserDept" runat="server" ReadOnly="true" CssClass="txt-readonly"
                            Width="250px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Designation
                    </td>
                    <td>
                        <asp:TextBox ID="txtReqUserPosCategory" runat="server" ReadOnly="true" CssClass="txt-readonly"
                            Width="250px"></asp:TextBox>
                    </td>
                    <td>
                        Mobile No
                    </td>
                    <td>
                        <asp:TextBox ID="txtReqUserMobNo" runat="server" onkeypress="return isNumberKey(this)"
                            Width="250px"></asp:TextBox>
                    </td>
                </tr>
            </asp:Panel>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Request Details
                </td>
            </tr>
            <tr>
                <td>
                    Request Category <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td>
                    <asp:DropDownList ID="ddlReqCategory" runat="server" AutoPostBack="false" Width="250px">
                    </asp:DropDownList>
                </td>
                <td>
                    Request Priority <span title="This is a required field." class="ms-validations"><strong>
                        *</strong></span>
                </td>
                <td align="left">
                    <asp:DropDownList ID="ddlReqPriority" runat="server" AutoPostBack="false" Width="250px">
                        <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                        <asp:ListItem Text="High" Value="High"></asp:ListItem>
                        <asp:ListItem Text="Medium" Value="Medium"></asp:ListItem>
                        <asp:ListItem Text="Low" Value="Low"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="tdHeadingTextLeftAlign">
                    Comments / Workflow Area
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 10px;">
                    <trig:ITComments ID="itComments" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 5px">
                    <table width="100%" cellpadding="0" cellspacing="0" class="Section-Approver">
                        <asp:Panel ID="pnlCommentArea" runat="server" class="Section-Approver">
                            <tr>
                                <td colspan="4" class="AppHeading">
                                    <strong>Comments</strong><span class="ms-validations" title="This is a required field."><strong>
                                        *</strong></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Image ID="ImgUser" runat="server" Height="50px" Width="50px" />
                                    <br />
                                    <asp:Label ID="LblCommentsUserName" runat="server" Font-Bold="True" Font-Size="XX-Small"
                                        ForeColor="#003399" Text=""></asp:Label>
                                </td>
                                <td colspan="3">
                                    <asp:TextBox ID="TxtComments" runat="server" TextMode="MultiLine" Width="600px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr id="upAtt" runat="server">
                                <td>
                                    Upload Attachment
                                </td>
                                <td colspan="3">
                                    <asp:FileUpload ID="upfile" runat="server" CssClass="ms-fileinput" Width="300px" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel ID="pnlForward" runat="server" Visible="false">
                            <tr>
                                <td colspan="4" style="text-align: left; background-color: #121e66; color: #ffffff;
                                    font-weight: bold; padding: 10px;">
                                    <table>
                                        <tr>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbSendBack" runat="server" Text="Send Back" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnSendBackUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbSendBack" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForwardOthers" runat="server" Text="Forward to other user"
                                                            AutoPostBack="true" GroupName="Users" onclick="javascript:fnForwardUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForwardOthers" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForward" runat="server" Text="Forward" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnForword(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForward" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                                    <ContentTemplate>
                                                        <asp:Label ID="lblWFStaticUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                        <asp:Label ID="lblSendBacktoUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow" Visible="false"></asp:Label>
                                                        <asp:Label ID="lblsendBackUserValue" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label></ContentTemplate>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr style="padding: 10px; display: none" id="trotherUsers">
                                <td style="padding: 10px; font-weight: bold; color: #121e66;" width="130px">
                                    User Name :
                                </td>
                                <td style="padding: 10px;" colspan="3">
                                    <asp:Label ID="lblCNTSectionMsg" runat="server" Text=""></asp:Label>
                                    <SharePoint:PeopleEditor ID="pplcnt" runat="server" MultiSelect="false" AllowEmpty="false"
                                        Width="300px" ForeColor="Red" AutoPostBack="false" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel runat="server" ID="btnCntrls">
                            <tr>
                                <td colspan="4">
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                        <ContentTemplate>
                                            <asp:Label ID="lblError" runat="server" CssClass="error-msg" Text=""></asp:Label>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" class="tblButtons" style="padding-top: 5px;">
                                    <asp:Button ID="btnSubmit" runat="server" CssClass="btn-Submit" Text="Submit" OnClientClick="javascript:return fnValidation();" />
                                    <asp:Button ID="btnApprove" runat="server" CssClass="btn-Approver" Text="Send Resolution to User"
                                        Width="250px" OnClientClick="javascript:return fnValidation();" Visible="false" />
                                    <asp:Button ID="btnReject" runat="server" CssClass="btn-Reject" Text="Cancel Request"
                                        Visible="false" Width="250px" OnClientClick="javascript:return fnValidation();" />
                                    <input id="btnCancel" class="btn-Cancel" type="button" value="Close" accesskey="C"
                                        runat="server" onclick="window.parent.history.back()" />
                                </td>
                            </tr>
                        </asp:Panel>
                    </table>
                </td>
            </tr>
            <asp:Panel ID="pnlView" runat="server" Visible="false">
                <tr>
                    <td colspan="4" style="text-align: center;">
                        <input id="btnViewClose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                            value="Close" accesskey="C" />
                    </td>
                </tr>
            </asp:Panel>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAccessDenied" runat="server" Visible="false">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="text-align: center;">
                    <asp:Label ID="lblAccessDeniedMsg" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                    <asp:Label ID="lblUserNotvailable" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px;">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/_layouts/1033/IMAGES/IRForm/AccessDeniedImage.png" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px">
                    <input id="butonclose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                        value="Close" accesskey="C" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <script language="javascript" type="text/javascript">

        function onSuccessMethod(sender, args) {

            var user = document.getElementById('<%= pplReqUser.ClientID  %>').value;
            var userObject = web.get_currentUser();
            var pplUser = userObject.get_title();
            var rval = true;

            if (pplUser == user) {
                rval = false;
            }
            return rval;
        }

        function onQueryFailed(sender, args) {
            alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
        }

        function ckUsers() {
            debugger;
            var rval = true;
            context = new SP.ClientContext.get_current();
            web = context.get_web();
            var currentUser = web.get_currentUser();
            alert(currentUser);
            currentUser.retrieve();
            context.load(web);
            rval = context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
            Function.createDelegate(this, this.onFailureMethod));
            return rval;
        }
    </script>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        var obj = document.getElementById('<%= rtbForwardOthers.ClientID%>');
        if (obj.checked == true)
            document.getElementById("trotherUsers").style.display = "inline";
        else
            document.getElementById("trotherUsers").style.display = "none";

        function fnForwardUsers(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "inline";
            else
                document.getElementById("trotherUsers").style.display = "none";

        }

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }

        function fnSendBackUsers(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "none";
        }
        function fnForword(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "none";
        }


        function isNumberKey(evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }


        function fnValidation() {
            debugger;
            isDateEmpty = false;

            var querystringval = getParameterByName('Mode');
            document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
            var rval = true;
            var ErrorMsg = "";
            var objFocus;

            Trim(document.getElementById('<%= rdBtn.ClientID  %>'));

            Trim(document.getElementById('<%= ddlReqCategory.ClientID  %>'));
            Trim(document.getElementById('<%= ddlReqPriority.ClientID  %>'));

            Trim(document.getElementById('<%= TxtComments.ClientID  %>'));


            if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                ErrorMsg = "Fields marked with (*) cannot be left blank";
                objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                rval = false;
            }

            var MyRadio = document.getElementById("<%=rdBtn.ClientID%>");
            var options = MyRadio.getElementsByTagName("input");
            var radVal;
            for (x = 0; x < options.length; ++x) {
                if (options[x].checked) {
                    radVal = x;
                }
            }

            var objDDl;

            objDDl = document.getElementById('<%=ddlReqPriority.ClientID%>');
            if (objDDl.value == "") {
                ErrorMsg = "Fields marked with (*) cannot be left blank";
                objFocus = document.getElementById('<%= ddlReqPriority.ClientID  %>');
                rval = false;

            }
            else {
                if (objDDl.options[objDDl.selectedIndex].value == "0") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= ddlReqPriority.ClientID  %>');
                    rval = false;
                }
            }

            objDDl = document.getElementById('<%=ddlReqCategory.ClientID%>');
            if (objDDl.value == "") {
                ErrorMsg = "Fields marked with (*) cannot be left blank";
                objFocus = document.getElementById('<%= ddlReqCategory.ClientID  %>');
                rval = false;

            }
            else {
                if (objDDl.options[objDDl.selectedIndex].value == "Select") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= ddlReqCategory.ClientID  %>');
                    rval = false;
                }
            }

            if (radVal == 1 && querystringval == "New") {
                Trim(document.getElementById('<%= pplReqUser.ClientID  %>'));

                if (document.getElementById('<%= pplReqUser.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= pplReqUser.ClientID  %>');
                    rval = false;
                }

            }

            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }
            return rval;
        }

    </script>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    IT Helpdesk
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    IT Helpdesk
</asp:Content>
